package com.leetCode.problem;

import java.util.HashMap;

/**
 * Description:
 * Copyright:   Copyright (c)2019
 * Company:     zefu
 *
 * @author: 张李鑫
 * @version: 1.0
 * Create at:   2021-11-02 17:06:28
 * <p>
 * Modification History:
 * Date         Author      Version     Description
 * ------------------------------------------------------------------
 * 2021-11-02     张李鑫                     1.0         1.0 Version
 */
public class Problem3 {
    /**
     * 给定一个字符串 s ，请你找出其中不含有重复字符的 最长子串 的长度。
     */


    public static int lengthOfLongestSubstring(String s) {
        if(s==null||s.length()==0){
            return 0;
        }
        int left=0;
        int right=0;
        int maxSize=1;
        char[]chars=s.toCharArray();
        for(int i=1;i<=s.length()-1;i++){
            for(int j=left;j<=right;j++){
                if(chars[i]==chars[j]){
                    left=j+1;
                }
            }
            right++;
            maxSize=Math.max(right-left+1,maxSize);
        }
        return maxSize;
    }

    public static void main(String[] args) {
        String a = "abba";
        int i = lengthOfLongestSubstring(a);
        System.out.println(i);
    }


}
